﻿namespace = shogunate_startup

# Setup For Living Characters (on game start, before lobby)
shogunate_startup.0001 = {
	scope = none
	hidden = yes

	immediate = {

		every_living_character = {

			# Promote Lowborn

			shogunate_promote_lowborn_effect = yes

			# Fictional Nicknames

			shogunate_fictional_nickname_effect = yes

			# Imperial Court Ranks

			if = {
				limit = {
					has_any_nickname = yes
				}
				change_imperial_court_post_effect = yes
			}

			# Change Marriage to Betrothal

			if = {
				limit = {
					is_married = yes
					is_adult = no
				}
				save_scope_as = actor
				every_spouse = {
					if = {
						limit = {
							matrilinear_marriage = no
						}
						divorce = scope:actor
						create_betrothal = scope:actor
					}
					else = {
						divorce = scope:actor
						create_betrothal_matrilineal = scope:actor
					}
				}
			}

			# Real Fathers and Adoptive Fathers

			if = {
				limit = {
					has_trait = child_of_adoption
					exists = this.father
					exists = this.real_father
					NOT = { this.father = this.real_father }
				}
				set_variable = {
					name = shogunate_adoptive_father
					value = this.father
				}
				set_variable = {
					name = shogunate_real_father
					value = this.real_father
				}
			}

			# stressed Trait (Compatibility with CK2)

			if = {
				limit = {
					has_trait = stressed
				}
				add_stress = massive_stress_impact_gain
				remove_trait = stressed
			}

			# is_fat Trait (Compatibility with CK2)

			if = {
				limit = {
					has_trait = is_fat
				}
				change_current_weight = 100
				change_target_weight  = 100
				target_weight_modifier_effect = { VALUE = 100 }
				remove_trait = is_fat
			}

			# Ainu Tattoo

			if = {
				limit = {
					culture = { has_cultural_pillar = heritage_ainu }
					is_female = yes
					age >= 10
				}
				add_character_flag = ainu_tattoo_flag
			}
		}
	}
}

# Setup For Living Characters (on game start, after lobby)
shogunate_startup.0002 = {
	scope = none
	hidden = yes

	immediate = {

#		every_living_character = {
#		}

	}
}

# Fill Bulding Slots (on game start)
shogunate_startup.2000 = {
	scope = none
	hidden = yes

	immediate = {
		every_province = {
			limit = {
				exists = county.holder
			}
			county.holder = { save_scope_as = holder }

			# Farms & Fields
			if = {
				limit = {
					building_cereal_fields_requirement_terrain = yes
					building_requirement_castle_city_church = { LEVEL = 01 }
					building_requirement_tribal = no
				}
				add_building = cereal_fields_01
			}
			# Forestry
			else_if = {
				limit = {
					building_logging_camps_requirement_terrain = yes
					building_requirement_castle_city_church = { LEVEL = 01 }
					building_requirement_tribal = no
				}
				add_building = logging_camps_01
			}
			# Quarries
			else_if = {
				limit = {
					building_quarries_requirement_terrain = yes
					building_requirement_castle_city_church = { LEVEL = 01 }
					building_requirement_tribal = no
				}
				add_building = quarries_01
			}
			# Pastoral Lands
			else_if = {
				limit = {
					building_pastures_requirement_terrain = yes
					building_requirement_castle_city_church = { LEVEL = 01 }
					building_requirement_tribal = no
				}
				add_building = pastures_01
			}
			# Wetland Farms
			else_if = {
				limit = {
					building_peat_quarries_requirement_terrain = yes
					building_requirement_castle_city_church = { LEVEL = 01 }
					building_requirement_tribal = no
				}
				add_building = peat_quarries_01
			}

			# Guilds
			if = {
				limit = {
					NOT = { scope:holder.top_liege = { government_has_flag = government_is_theocracy } }
					building_requirement_castle_city_church = { LEVEL = 01 }
					building_requirement_tribal = no
				}
				add_building = guild_halls_01
			}

			# Monasteries
			if = {
				limit = {
					scope:holder.top_liege = { government_has_flag = government_is_theocracy }
					building_requirement_castle_city_church = { LEVEL = 01 }
					building_requirement_tribal = no
				}
				add_building = monastic_schools_01
			}

			# Tribal Buildings (Gathering Halls, Markets)
			if = {
				limit = {
					building_requirement_tribal = yes
					has_building_or_higher = tribe_01
				}
				add_building = longhouses_01
				add_building = market_villages_01
			}
		}
	}
}
